#include "parameter.h"



sys_p::sys_p()
{
	cname       = "sys_p";
	defaultfile = "plist";
//	initialize();
//	checkout();
}




void sys_p::initialize0()
{
	newrun  = true;
	bins    = false;
	nosE    = false;
	
	kbstart = 1;
	maxkb   = 1000;
	kbskp   = 500;
	kbskpi  = 200;
	kbmv1   = 100;
	kbmv2   = 200;
	kbtraj  = 100;
	iwrite  = maxkb;
	jwrite  = 100;
	
	tr0    = 1.;
	tr1    = 1.;
	delta  = 0.005;
	u0     = 0 * delta;
	u1     = 0 * delta;
	g      = 0.01;
	fwall  = 100.;
	cwf    = 1.;
}




bool sys_p::checkout(char* file)
{
	int i;
	
	read(file);
	for (i = 0; i < n_bool; i++) {
		if(bps_name[i] == "newrun"){
			newrun = bps[i];
			cout<<"newrun = "<<newrun<<endl;
			continue;
		}
		if(bps_name[i] == "bins"){
			bins = bps[i];
			cout<<"bins = "<<bins<<endl;
			continue;
		}
		if(bps_name[i] == "nosE"){
			nosE = bps[i];
			cout<<"nosE = "<<nosE<<endl;
			continue;
		}
	}

	for (i = 0; i < n_int; i++) {
		if(ips_name[i] == "kbstart"){
			kbstart = ips[i];
			cout<<"kbstart = "<<kbstart<<endl;
			continue;
		}
		if(ips_name[i] == "maxkb"){
			maxkb = ips[i];
			cout<<"maxkb = "<<maxkb<<endl;
			continue;
		}
		if(ips_name[i] == "kbskp"){
			kbskp = ips[i];
			cout<<"kbskp = "<<kbskp<<endl;
			continue;
		}
		if(ips_name[i] == "kbskpi"){
			kbskpi = ips[i];
			cout<<"kbskpi = "<<kbskpi<<endl;
			continue;
		}
		if(ips_name[i] == "kbmv1"){
			kbmv1 = ips[i];
			cout<<"kbmv1 = "<<kbmv1<<endl;
			continue;
		}
		if(ips_name[i] == "kbmv2"){
			kbmv2 = ips[i];
			cout<<"kbmv2 = "<<kbmv2<<endl;
			continue;
		}
		if(ips_name[i] == "kbtraj"){
			kbtraj = ips[i];
			cout<<"kbtraj = "<<kbtraj<<endl;
			continue;
		}
		if(ips_name[i] == "iwrite"){
			iwrite = ips[i];
			cout<<"iwrite = "<<iwrite<<endl;
			continue;
		}
		if(ips_name[i] == "jwrite"){
			jwrite = ips[i];
			cout<<"jwrite = "<<jwrite<<endl;
			continue;
		}
	}

	for (i = 0; i<n_real; i++) {
		if(rps_name[i] == "tr0"){
			tr0 = rps[i];
			cout<<"tr0 = "<<tr0<<endl;
			continue;
		}
		if(rps_name[i] == "tr1"){
			tr1 = rps[i];
			cout<<"tr1 = "<<tr1<<endl;
			continue;
		}
		if(rps_name[i] == "delta"){
			delta = rps[i];
			cout<<"delta = "<<delta<<endl;
			continue;
		}
		if(rps_name[i] == "u0"){
			u0 = rps[i];
			cout<<"u0 = "<<u0<<endl;
			continue;
		}
		if(rps_name[i] == "u1"){
			u1 = rps[i];
			cout<<"u1 = "<<u1<<endl;
			continue;
		}
		if(rps_name[i] == "g"){
			g = rps[i];
			cout<<"g = "<<g<<endl;
			continue;
		}
		if(rps_name[i] == "fwall"){
			fwall = rps[i];
			cout<<"fwall = "<<fwall<<endl;
			continue;
		}
		if(rps_name[i] == "cwf"){
			cwf = rps[i];
			cout<<"cwf = "<<cwf<<endl;
			continue;
		}
	}

	return true;
}




bool sys_p::checkout()
{
	return checkout(defaultfile);
}




sys_v::sys_v()
{
	cname       = "sys_v";
	defaultfile = "vlist";
	if_c_d_rc   = false;
//	initialize();
//	checkout();
}




void sys_v::initialize0()
{
	edb    = 0.;
	elj    = 0.;
	eth    = 0.;
}




bool sys_v::checkout(char* file)
{
	int i;
	
	read(file);
	for (i = 0; i<n_int; i++) {
		if(ips_name[i] == "kb"){
			kb = ips[i];
			cout<<"kb = "<<kb<<endl;
			continue;
		}
	}
	for (i = 0; i<n_real; i++) {
		if(rps_name[i] == "ux"){
			ux = rps[i];
			cout<<"ux = "<<ux<<endl;
			continue;
		}
		if(rps_name[i] == "uy"){
			uy = rps[i];
			cout<<"uy = "<<uy<<endl;
			continue;
		}
		if(rps_name[i] == "uz"){
			uz = rps[i];
			cout<<"uz = "<<uz<<endl;
			continue;
		}
		if(rps_name[i] == "edb"){
			edb = rps[i];
			cout<<"edb = "<<edb<<endl;
			continue;
		}
		if(rps_name[i] == "elj"){
			elj = rps[i];
			cout<<"elj = "<<elj<<endl;
			continue;
		}
		if(rps_name[i] == "eth"){
			eth = rps[i];
			cout<<"eth = "<<eth<<endl;
			continue;
		}
	}
	return true;
}




bool sys_v::checkout()
{
	return checkout(defaultfile);
}



/*
int main()
{
	sys_p p;
	sys_v v;
	

//	initialize function is to build up the parameter list from parameter.h
//	checkout function is to assign values to all the parameters from plist or vlist
//	initialize should be always called before checkout

	p.initialize();
	p.checkout();
	
	v.initialize();
	v.checkout();
	
	
	return 0;
}*/